module.exports = {
  data: {
    openId: '',
  },
  openId(openId) {
      console.log('openId',openId)
      this.setData({
        openId:openId
      });
  },
  onLoad:async function (){
      let openId= wx.getStorageSync('openId');
      if (openId == undefined || openId=="") {
        console.log("wx.cloud获取")
        const func=new Promise((resolve, reject)=>{
          wx.cloud.callFunction({
            name:"login",
            data:{}
          }).then(x=>{
            wx.setStorageSync('openId', x.result.openid)
            resolve(x.result.openid)
          })
        });
        openId= await func;
      }
      this.openId(openId);
  },
  onUnload() {
  },
};